//
//  WYHotIndustryCell.m
//  Boss
//
//  Created by admin on 2018/6/23.
//  Copyright © 2018年 admin. All rights reserved.
//

#import "WYHotIndustryCell.h"
#import "SCAdCollectionViewLayout.h"
#import "WYHotIndustryCollectionViewCell.h"
#import "WYHotSector.h"
#import "SCAdView.h"
@interface WYHotIndustryCell()<UICollectionViewDataSource,UICollectionViewDelegate,SCCollectionViewFlowLayoutDelegate>
@property (strong, nonatomic) IBOutlet UICollectionView *collectionView;




@end
@implementation WYHotIndustryCell
-(void)setDataArray:(NSArray *)dataArray
{
    _dataArray = dataArray;
    [self.collectionView reloadData];
}
- (void)awakeFromNib {
    [super awakeFromNib];
    [self setUpUI];
    // Initialization code
}
-(void)setUpUI
{
    self.collectionView.dataSource=self;
    self.collectionView.delegate = self;
    
    SCAdCollectionViewLayout *layout = [SCAdCollectionViewLayout new];
    layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    layout.itemSize = (CGSize){kScreenWidth-60,kScreenWidth/2.f};;
    layout.minimumLineSpacing =0;
//    layout.minimumInteritemSpacing = builder.minimumInteritemSpacing;
    layout.secondaryItemMinAlpha = 1.0f;
    layout.threeDimensionalScale =1.45;
    layout.delegate = self;
    layout.cycleIndex =-1;
   // _layout = layout;
//    if(_builder.autoScrollDirection>1){
//        CGFloat y_inset =(self.frame.size.height-layout.itemSize.height) / 2.f;
//        layout.sectionInset = UIEdgeInsetsMake(y_inset,0,y_inset,0);
//    }else{
//        CGFloat x_inset =(self.frame.size.width-layout.itemSize.width) / 2.f;
//        layout.sectionInset = UIEdgeInsetsMake(0, x_inset, 0, x_inset);
//    }
    [self.collectionView setCollectionViewLayout:layout];
    [self.collectionView registerNib:[UINib nibWithNibName:@"WYHotIndustryCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"WYHotIndustryCollectionViewCell"];
}


#pragma mark -collection delegate/datasource
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return self.dataArray.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    WYHotIndustryCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"WYHotIndustryCollectionViewCell" forIndexPath:indexPath];
    if (!cell) {
        cell = [[NSBundle mainBundle]loadNibNamed:@"WYHotIndustryCollectionViewCell" owner:nil options:nil].firstObject;
    }
    
    WYHotSector *hotSector = self.dataArray[indexPath.row];
    
    [cell.hotImageView sd_setImageWithURL:[NSURL URLWithString:hotSector.url] placeholderImage:[UIImage imageNamed:@"icon_hot_placeholder"]];
    
    
    return cell;
}


-(void)sc_collectioViewScrollToIndex:(NSInteger)index
{
    NSLog(@"%ld",index);
}












- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
